package com.edfu.core.commons.exceptions;

import com.edfu.core.util.ExceptionUtils;

public class UncheckedException extends RuntimeException implements EduBaseException {

	private static final long serialVersionUID = -5289397390482019187L;
	
	private final String errorCode;
	private final String localizedMessage;
	
	public UncheckedException(String errorCode, Object... messageArgs) {
        this(errorCode, null, messageArgs);
    }
	
	public UncheckedException(String errorCode, Exception cause, Object... messageArgs) {
		super(ExceptionUtils.buildErrorMessage(errorCode, cause, messageArgs), cause);
		this.errorCode = errorCode;
		this.localizedMessage = ExceptionUtils.buildLocalizedErrorMessage(errorCode, cause, messageArgs);
	}

	@Override
	public String getErrorCode() {
		return errorCode;
	}
	
	@Override
	public String getLocalizedMessage() {
		return localizedMessage != null ? localizedMessage : getMessage();
	}

}
